package org.filecollector.msgcontroller;

import lombok.AllArgsConstructor;
import org.filecollector.msgcontroller.answers.SyncAnswerMessage;
import org.filecollector.msgcontroller.listener.BasicsListener;
import org.filecollector.msgcontroller.requests.SyncRequestMessage;
import org.filecollector.msgcontroller.writer.BasicsWriter;

@AllArgsConstructor
class MSGControllerClass implements MSGController {
    final BasicsListener listener;
    final BasicsWriter writer;

    @Override
    public SyncRequestMessage read() {
        return SyncRequestMessage.deserialize(listener.readNext());
    }

    @Override
    public void write(SyncAnswerMessage msg) {
        writer.write(msg.serialize());
    }
}
